/**
 * 
 */
package com.rs.controller;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import com.rs.model.ZhAttendance;
import com.rs.service.ZhAttendanceService;
import com.rs.util.SpringContextUtils;
import java.awt.Toolkit;
import javax.swing.SpringLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JComboBox;

/**
 * @author zjw
 *
 */
public class AttendanceUpdate extends JFrame {

	private JPanel contentPane;
	private JTextField txt_uname;
	private JTextField txt_am_type;
	private JTextField txt_noon_type;
	private JTextField txt_pm_type;
	private JTextField txt_night_type;
	private JTextField txt_am_datetime;
	private JTextField txt_noon_datetime;
	private JTextField txt_pm_datetime;
	private JTextField txt_night_datetime;
	private JTextField txt_date;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					AttendanceUpdate frame = new AttendanceUpdate();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public AttendanceUpdate() {
		setAlwaysOnTop(true);
		setResizable(false);
		setTitle("教师考勤详情");
		setIconImage(Toolkit.getDefaultToolkit().getImage(AttendanceUpdate.class.getResource("/images/logo1.png")));
//		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 710, 477);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		SpringLayout sl_contentPane = new SpringLayout();
		contentPane.setLayout(sl_contentPane);
		
		JLabel lb_uname = new JLabel("名称");
		contentPane.add(lb_uname);
		
		txt_uname = new JTextField();
		txt_uname.setEnabled(false);
		sl_contentPane.putConstraint(SpringLayout.NORTH, txt_uname, 43, SpringLayout.NORTH, contentPane);
		sl_contentPane.putConstraint(SpringLayout.WEST, txt_uname, 110, SpringLayout.WEST, contentPane);
		sl_contentPane.putConstraint(SpringLayout.EAST, txt_uname, -466, SpringLayout.EAST, contentPane);
		sl_contentPane.putConstraint(SpringLayout.NORTH, lb_uname, 3, SpringLayout.NORTH, txt_uname);
		contentPane.add(txt_uname);
		txt_uname.setColumns(10);
		
		txt_am_type = new JTextField();
		sl_contentPane.putConstraint(SpringLayout.NORTH, txt_am_type, 73, SpringLayout.SOUTH, txt_uname);
		sl_contentPane.putConstraint(SpringLayout.WEST, txt_am_type, 0, SpringLayout.WEST, txt_uname);
		sl_contentPane.putConstraint(SpringLayout.EAST, txt_am_type, 0, SpringLayout.EAST, txt_uname);
		contentPane.add(txt_am_type);
		txt_am_type.setColumns(10);
		
		txt_am_datetime = new JTextField();
		sl_contentPane.putConstraint(SpringLayout.NORTH, txt_am_datetime, 0, SpringLayout.NORTH, txt_am_type);
		sl_contentPane.putConstraint(SpringLayout.WEST, txt_am_datetime, 78, SpringLayout.EAST, txt_am_type);
		sl_contentPane.putConstraint(SpringLayout.EAST, txt_am_datetime, -267, SpringLayout.EAST, contentPane);
		contentPane.add(txt_am_datetime);
		txt_am_datetime.setColumns(10);
		
		JLabel lb_noon = new JLabel("中午");
		sl_contentPane.putConstraint(SpringLayout.EAST, lb_noon, -603, SpringLayout.EAST, contentPane);
		sl_contentPane.putConstraint(SpringLayout.WEST, lb_uname, 0, SpringLayout.WEST, lb_noon);
		contentPane.add(lb_noon);
		
		txt_noon_type = new JTextField();
		sl_contentPane.putConstraint(SpringLayout.WEST, txt_noon_type, 110, SpringLayout.WEST, contentPane);
		sl_contentPane.putConstraint(SpringLayout.NORTH, lb_noon, 3, SpringLayout.NORTH, txt_noon_type);
		sl_contentPane.putConstraint(SpringLayout.NORTH, txt_noon_type, 20, SpringLayout.SOUTH, txt_am_type);
		sl_contentPane.putConstraint(SpringLayout.EAST, txt_noon_type, 0, SpringLayout.EAST, txt_uname);
		contentPane.add(txt_noon_type);
		txt_noon_type.setColumns(10);
		
		txt_noon_datetime = new JTextField();
		sl_contentPane.putConstraint(SpringLayout.NORTH, txt_noon_datetime, -3, SpringLayout.NORTH, lb_noon);
		sl_contentPane.putConstraint(SpringLayout.WEST, txt_noon_datetime, 0, SpringLayout.WEST, txt_am_datetime);
		sl_contentPane.putConstraint(SpringLayout.EAST, txt_noon_datetime, -267, SpringLayout.EAST, contentPane);
		contentPane.add(txt_noon_datetime);
		txt_noon_datetime.setColumns(10);
		
		JLabel lb_pm = new JLabel("下午");
		contentPane.add(lb_pm);
		
		txt_pm_type = new JTextField();
		sl_contentPane.putConstraint(SpringLayout.EAST, lb_pm, -19, SpringLayout.WEST, txt_pm_type);
		sl_contentPane.putConstraint(SpringLayout.NORTH, txt_pm_type, 18, SpringLayout.SOUTH, txt_noon_type);
		sl_contentPane.putConstraint(SpringLayout.NORTH, lb_pm, 3, SpringLayout.NORTH, txt_pm_type);
		sl_contentPane.putConstraint(SpringLayout.WEST, txt_pm_type, 0, SpringLayout.WEST, txt_uname);
		sl_contentPane.putConstraint(SpringLayout.EAST, txt_pm_type, 0, SpringLayout.EAST, txt_uname);
		contentPane.add(txt_pm_type);
		txt_pm_type.setColumns(10);
		
		txt_pm_datetime = new JTextField();
		sl_contentPane.putConstraint(SpringLayout.NORTH, txt_pm_datetime, -3, SpringLayout.NORTH, lb_pm);
		sl_contentPane.putConstraint(SpringLayout.WEST, txt_pm_datetime, 78, SpringLayout.EAST, txt_pm_type);
		sl_contentPane.putConstraint(SpringLayout.EAST, txt_pm_datetime, 0, SpringLayout.EAST, txt_am_datetime);
		contentPane.add(txt_pm_datetime);
		txt_pm_datetime.setColumns(10);
		
		JLabel lb_nigth = new JLabel("晚上");
		sl_contentPane.putConstraint(SpringLayout.NORTH, lb_nigth, 31, SpringLayout.SOUTH, lb_pm);
		contentPane.add(lb_nigth);
		
		txt_night_type = new JTextField();
		sl_contentPane.putConstraint(SpringLayout.EAST, lb_nigth, -19, SpringLayout.WEST, txt_night_type);
		sl_contentPane.putConstraint(SpringLayout.NORTH, txt_night_type, -3, SpringLayout.NORTH, lb_nigth);
		sl_contentPane.putConstraint(SpringLayout.WEST, txt_night_type, 0, SpringLayout.WEST, txt_uname);
		sl_contentPane.putConstraint(SpringLayout.EAST, txt_night_type, 0, SpringLayout.EAST, txt_uname);
		contentPane.add(txt_night_type);
		txt_night_type.setColumns(10);
		
		txt_night_datetime = new JTextField();
		sl_contentPane.putConstraint(SpringLayout.NORTH, txt_night_datetime, -3, SpringLayout.NORTH, lb_nigth);
		sl_contentPane.putConstraint(SpringLayout.WEST, txt_night_datetime, 78, SpringLayout.EAST, txt_night_type);
		sl_contentPane.putConstraint(SpringLayout.EAST, txt_night_datetime, 0, SpringLayout.EAST, txt_am_datetime);
		contentPane.add(txt_night_datetime);
		txt_night_datetime.setColumns(10);
		
		JLabel lb_am = new JLabel("早上");
		sl_contentPane.putConstraint(SpringLayout.SOUTH, lb_am, 0, SpringLayout.SOUTH, txt_am_type);
		sl_contentPane.putConstraint(SpringLayout.EAST, lb_am, -19, SpringLayout.WEST, txt_am_type);
		contentPane.add(lb_am);
		
		JLabel lb_date = new JLabel("日期");
		sl_contentPane.putConstraint(SpringLayout.NORTH, lb_date, 33, SpringLayout.SOUTH, lb_uname);
		contentPane.add(lb_date);
		
		txt_date = new JTextField();
		txt_date.setEnabled(false);
		sl_contentPane.putConstraint(SpringLayout.EAST, lb_date, -19, SpringLayout.WEST, txt_date);
		sl_contentPane.putConstraint(SpringLayout.NORTH, txt_date, -3, SpringLayout.NORTH, lb_date);
		sl_contentPane.putConstraint(SpringLayout.WEST, txt_date, 0, SpringLayout.WEST, txt_uname);
		sl_contentPane.putConstraint(SpringLayout.EAST, txt_date, -5, SpringLayout.EAST, txt_uname);
		contentPane.add(txt_date);
		txt_date.setColumns(10);
		
		
	}
	
	public void select(Object id){
		ZhAttendance attendance = new ZhAttendance();
		attendance.setAt_id(Integer.parseInt(id+""));
		System.out.println(id);
		ZhAttendanceService attendanceservice = SpringContextUtils.getBean(ZhAttendanceService.class);		
		ZhAttendance att = attendanceservice.attendanceSelectByTiaojian(attendance).getList().get(0);
		
		txt_uname.setText(att.getU_name());
		txt_date.setText(att.getAt_days());
		txt_am_type.setText(att.getAt_amtype1());
		txt_noon_type.setText(att.getAt_noontype1());
		txt_pm_type.setText(att.getAt_pmtype1());
		txt_night_type.setText(att.getAt_nighttype1());
		txt_am_datetime.setText(att.getAt_amtimes());
		txt_noon_datetime.setText(att.getAt_noontimes());
		txt_pm_datetime.setText(att.getAt_pmtimes());
		txt_night_datetime.setText(att.getAt_nighttimes());
	}
}
